package com.carrental.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.carrental.service.CarListService;

/**
 * Servlet implementation class CarListDeleteServlet
 */
@WebServlet("/CarListDeleteServlet")
public class CarListDeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	CarListService carListService;
	
    /**
     * @throws Exception 
     * @see HttpServlet#HttpServlet()
     */
    public CarListDeleteServlet() throws Exception {
        super();
        carListService = new CarListService();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("id");
		
		System.out.println("删除汽车：id：" + id);
		
		try {
			carListService.delete(id);
			response.sendRedirect("admin.jsp");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

}
